#ifndef SERIALPLOT_H
#define SERIALPLOT_H

#include <QObject>
#include <QSerialPort>

#include <QTimer>
class SerialPlot : public QObject
{
    Q_OBJECT
public:
    explicit SerialPlot(QObject *parent = nullptr);
    ~SerialPlot();
    typedef struct COMINFO{
        QString name;
        int     baud;
        int     dataBits;
        QString parity;
        float   stopBits;
    }COMINFO;

public:
    //bool connectCOM(COMINFO info);




    void displayformat(bool hex_en);
public slots:
    void connectCOM(COMINFO info);
    void closeCOM();
    void send(char *data,int len);
    void sendFile(QString filename,int pageSize,int delay);
    void ScanTimecallback();
    void readcallback();
    void errorcallback(QSerialPort::SerialPortError);


signals:
    void ScanTimeSignals(QStringList);  //扫描到的串口
    void readSignals(QByteArray , QString hex_string);       //接收到串口数据
    void serialState(bool isCon);        //串口是否连接
    void sendFileCSize(int size);        //当前文件发送的大小
private:
    QTimer *serialScanTime;
    QSerialPort *serialPort;
    bool serialconnect = false;
public:
    bool hex_display = false;
};

#endif // SERIALPLOT_H
